package com.neuedu.service.impl;

import com.neuedu.dao.StockDao;
import com.neuedu.model.Stock;
import com.neuedu.service.StockService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class StockServiceImpl implements StockService {
    @Autowired
    private StockDao stockDao;

    @Override
    public Stock queryStockById(Integer sid) {
        Stock stock = stockDao.selectById(sid);
        return stock;
    }

    @Override
    public void addStock(Stock stock) {
        stockDao.addStock(stock);
    }

    @Override
    public boolean reduceStock(Integer sid, Integer quantity) {
        int rows = stockDao.reduceStock(sid, quantity);
        return rows > 0;
    }

    @Override
    public Stock addRemark(Integer sid, String remark) {
        return null;
    }

    @Override
    public void increaseStock(Stock stock) {
        stockDao.insert(stock);
    }
}
